<?php

define('E_COULD_NOT_CREATE','Error: Could not create %s!');
define('E_COULD_NOT_WRITE','Error: Could not write to %s directory!');

// Autoloader
include_once(DIR_LIBRARY . 'autoloader.php');


class Locator {	
	
	var $data = array();
	
	function &get($key) {
		if (!isset($this->data[$key])) $this->data[$key] =& $this->create($key);
		return $this->data[$key];
	}
	
	function set($key, &$value) {
		$this->data[$key] =& $value;
	}
		
	function create($key) {
		$method = 'create'.$key;
		if (method_exists($this, $method)) { return $this->$method(); }
		if (class_exists($key)) return new $key($this);
		exit(sprintf(E_COULD_NOT_CREATE,$key));
	}
	
	//function createTemplate() {
	//	require_once(DIR_LIBRARY.'template/template.php');
		//$config =& $this->get('config');
		//return new Template($this,$config->get('config_template'));
	//}
}
?>